package com.cj.sys.entity.security;

import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.cj.common.entity.IdEntity;
import com.cj.common.entity.Parent;
@Entity
@Table(name = "DEPT")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE,region="Dept")
public class Dept extends IdEntity {
	public Dept(Long id) {
		super.setId(id);
	}
	public Dept() {
	}
	
	@Parent
	private Dept parent;
	private String code;
	private String name;
	private String leader;
	private Integer orderNum;
	private String type;
//	private Integer isstop;
	private	String	fullName;
	private	Date	createTime;
	private Set<Dept> children = new LinkedHashSet<Dept>(); // 有序的关联对象集合.

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "PARENT")
	public Dept getParent() {
		return parent;
	}
	public void setParent(Dept parent) {
		this.parent = parent;
	}
	@Column(nullable=false)
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	@Column(nullable=false)
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getLeader() {
		return leader;
	}
	public void setLeader(String leader) {
		this.leader = leader;
	}
	public Integer getOrderNum() {
		return orderNum;
	}
	public void setOrderNum(Integer orderNum) {
		this.orderNum = orderNum;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	@OneToMany(mappedBy = "parent")
	public Set<Dept> getChildren() {
		return children;
	}
	public void setChildren(Set<Dept> children) {
		this.children = children;
	}
	public String getFullName() {
		return fullName;
	}
	public void setFullName(String fullName) {
		this.fullName = fullName;
	}
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
}
